<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

<h:head></h:head> 
<body> 
	<ui:composition template="../../template.xhtml">
		<ui:define name="content">
		
             <h:messages></h:messages>
             <div>
             	<div class="pull-right">
             		<h:form>
						<h:commandLink value="Inserisci Escursione" action="#{excursionBackend.createAction}" styleClass="btn btn-default"></h:commandLink>
					</h:form>
				</div>
             </div>
          	
          	
          	<h:dataTable value="#{excursionBackend.list}" var="item"
    			styleClass="table"
    			headerClass=""
    			rowClasses=""
    		>
 
    			<h:column>
    				<!-- column header -->
    				<f:facet name="header">Nome</f:facet>
    				<!-- row record -->
    				#{item.name}
    			</h:column>
 
    			<h:column>
    				<f:facet name="header">Luogo</f:facet>
    				#{item.product.place.name}
    			</h:column>
    			
    			<h:column>
    				<f:facet name="header">Data</f:facet>
    				<h:outputText value="#{item.date}">
					    <f:convertDateTime pattern="dd/MM/yyyy" type="date" />
					</h:outputText>
    			</h:column>
 
    			<h:column>
    				<f:facet name="header">Durata</f:facet>
    				#{item.duration}
    			</h:column>
    			
    			<h:column>
    				<f:facet name="header">Prezzo</f:facet>
    				#{item.product.price} &euro;
    			</h:column>
    			
    			<h:column>
    				<f:facet name="header">Azioni</f:facet>
    				<h:form>
	    				<ul>
	    					<li>
	    						<h:commandLink value="modifica" action="#{excursionBackend.editAction(item.product.id)}"></h:commandLink>
					   		</li>
	    					<li>
							   	<h:commandLink value="elimina" action="#{excursionBackend.deleteAction(item.product.id)}"></h:commandLink>
	    					</li>
	    				</ul>
	   					
				   	</h:form>
    			</h:column>
 
    		</h:dataTable>
    	</ui:define>
    </ui:composition>
</body> 
</html>
